const {Builder, By, Key, until} = require('selenium-webdriver');

(async function example() {
  // Create a new instance of the chrome driver
  let driver = await new Builder().forBrowser('chrome').build();

  try {
    //自动打开百度并搜索黑马程序员
    await driver.get('https://www.baidu.com/');
    // 找到元素，想里面发送一个关键字并按回车
    await driver.findElement(By.id('kw')).sendKeys('黑马程序员', Key.RETURN);
    await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
  } finally {
    // Close the browser
    //await driver.quit();
  }
  
})();